*** Settings ***
Documentation           通过Redfis获取所有资源的schema文件
Resource                ../../test_function/redfish/redfish.robot
Resource                ../../test_function/resource.robot
Library                 RequestsLibrary
Library                 Collections
Library                 BuiltIn
Suite Setup             Create REDFISH_GET Session
Suite Teardown          Delete All Sessions

*** Variables ***
${INPUT_URI}            /JSONSchemas

*** Test Cases ***
Get Schema Resource Via Redfish
    [Documentation]    通过Redfish查询所有资源的schema文件
    [Tags]    Get_Schema_Resource_Via_Redfish
    # 发送GET请求
    ${rsp}=    Run Keyword And Ignore Error    GET On Session    redfish_get    ${INPUT_URI}

    Run Keyword If     '${rsp[0]}' == 'FAIL'    Fail    msg=获取schema文件失败: ${rsp[1]}

    # 验证响应状态码
    Should Be Equal As Strings    ${rsp[1].status_code}    ${SUCCESS_CODE}    msg=预期状态码200,实际收到${rsp[1].status_code}

    # 打印响应内容
    Log    ${rsp[1].json()}    level=INFO

    # 验证所有资源的Schema的odata.id：Attributes
    ${output_settings}=    Set Variable    ${rsp[1].json()}
    ${id}=    Set Variable    /redfish/v1/JSONSchemas/SessionCollection
    ${odata_id}=    Create Dictionary    @odata.id=${id}

    # 检查响应中是否包含Atrributes
    Should Contain    ${output_settings['Members']}    ${odata_id}
    Log    所有资源的schema文件的值之一为: ${output_settings['Members']}    level=INFO
